﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Camalot.Common.Extensions {
	public static partial class CamalotCommonExtensions {
		public static T Random<T> ( this IEnumerable<T> source ) {
			return source.OrderBy ( x => Guid.NewGuid ( ) ).FirstOrDefault ( );
		}

		public static void ForEach<T> ( this IEnumerable<T> source, Action<T> action ) {
			if ( source == null || source.Count() == 0 ) { 
				return;
			}
			foreach ( var item in source ) {
				action ( item );
			}
		}
	}
}
